package com.cjq.oss.controller;


import com.cjq.oss.service.OssService;
import com.cjq.utils.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;

@RestController
@RequestMapping("/oss/fileOss")
@CrossOrigin
public class OssController {

    @Autowired
    private OssService ossService;


    @ApiOperation("上传文件到阿里云oss")
    @PostMapping("/uploadFile")
    public R uploadFile(MultipartFile file){
        String s = ossService.uploadFileAvatar(file);
        return R.succ().data("url",s);
    }

    @ApiOperation("进行多张图片的上传")
    @PostMapping("/uploadSomeFile")
    public R uploadSomeFile(MultipartFile file, @RequestParam ArrayList<String> imageList){
        String s = ossService.uploadFileAvatar(file);
        imageList.add(s);
        return R.succ().data("list",imageList);
    }


}
